﻿@page "/Wms/OtherOutWarehouse/BatchEdit"
@using nERP.ViewModel.Wms.OtherOutWarehouseVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
    <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
        <Select @bind-Value="@Model.LinkedVM.OtherOutTypeId" Items="AllOtherOutTypes" />
        <Select @bind-Value="@Model.LinkedVM.MakeUserId" Items="AllMakeUsers" />
        <DateTimePicker @bind-Value="@Model.LinkedVM.InvoicesDate" />
        <Select @bind-Value="@Model.LinkedVM.Status" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.Remark" />
    </Row>

    <div class="modal-footer table-modal-footer">
        <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]" />
        <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
    </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private OtherOutWarehouseBatchVM Model = new OtherOutWarehouseBatchVM();
    private ValidateForm vform { get; set; }

    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/OtherOutWarehouse/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }


    public void OnClose()
    {
        CloseDialog();
    }

    private List<SelectedItem> AllOtherOutTypes = new List<SelectedItem>();
    private List<SelectedItem> AllMakeUsers = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {


        AllOtherOutTypes = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherOutWarehouse/GetDicFields出库业务类别");
        AllOtherOutTypes.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllMakeUsers = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherOutWarehouse/GetFrameworkUsers");
        AllMakeUsers.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });

        await base.OnInitializedAsync();
    }
}
